package su.fishr.display 
{
	
	   

	/**
	 *   Получает в аргументах инициализации значение цвета ( включая альфу ).
	 * Изменяет цветовые каналы полученного цвета. Возвращает числовое и 
	 * строковое представление каждого из цветовых каналов. хранимого значения
	 * цвета.
	 * 
	 * @playerversion          Flash 9
	 * @langversion            3.0
	 * @created                10/2/2012 6:05 AM
	 * @since                  10/2/2012 6:05 AM
	 */
	public  class PixelMoock
	{
		
	/**-------------------------------------------------------------------------------
	* 
	*	   						V A R I A B L E ' S 	
	* 
	* --------------------------------------------------------------------------------
	*/
	//{
		
		private var value:uint;
		
	//}
	
	/**-------------------------------------------------------------------------------
	* 
	*	 						P R O P E R T I E S 	
	* 
	* --------------------------------------------------------------------------------
	*/
	//{
	
	//}
	/**-------------------------------------------------------------------------------
	* 
	*								P U B L I C 	
	* 
	* --------------------------------------------------------------------------------
	*/
	//{
		public function PixelMoock( n1:uint = 0xFF, n2:int = 0, n3:int = 0, n4:int = 0 )
		{
			if ( arguments.length === 1 )
			{
				value = n1;
			}
			else
			{
				value = n1 << 24 | n2 << 16 | n3 << 8 | n4;
			}
			
		}
		
		public function setAlpha( n:int ):void
		{
			if ( n < 0 || n > 255 )throw new RangeError( "Supplled value must be in the range 0-255 );
			
			value &= ( 0x00FFFFFF );
			value |= ( n << 24 );
		}
		
		public function setRed( n:int ):void
		{
			if ( n < 0 || n > 255 ) throw new RangeError( "Supplled value must be in the range 0-255 );
			
			value &= ( 0xFF00FFFF );
			value |= ( n << 16 );
		}
		
		public function setGreen( n:int ):void
		{
			if ( n < 0 || n > 255 ) throw new RangeError( "Supplled value must be in the range 0-255 );
			
			value &= ( 0xFFFF00FF );
			value |= ( n << 8 );
		}
		
		public function setBlue( n:int ):void
		{
			if ( n < 0 || n > 255 ) throw new RangeError( "Supplled value must be in the range 0-255 );
			
			value &= ( 0xFFFFFF00 );
			value |=  n;
		}
		
		public function getAlpha():int
		{
			return ( value >> 24 ) & 0xFF;
		}
		
		public function getRed():int
		{
			return ( value >> 16 ) & 0xFF;
		}
		
		public function getGreen():int
		{
			return ( value >> 8 ) & 0xFF;
		}
		
		public function getBlue():int
		{
			return  value  & 0xFF;
		}
		
		public function toString():String
		{
			return toStringARGB();
		}
		
		
		public function toStringAlpha( radix:int = 16 ):String
		{
			return (( value >> 24 ) & 0xFF ).toString( radix ).toUpperCase();
		}
		
		public function toStringRed( radix:int = 16 ):String
		{
			return (( value >> 16 ) & 0xFF ).toString( radix ).toUpperCase();
		}
		
		public function toStringGreen( radix:int = 16 ):String
		{
			return (( value >> 8 ) & 0xFF ).toString( radix ).toUpperCase();
		}
		
		public function toStringBlue( radix:int = 16 ):String
		{
			return ( value  & 0xFF ).toString( radix ).toUpperCase();
		}
	//}
	
	/**-------------------------------------------------------------------------------
	* 
	*								P R I V A T E 	
	* 
	* --------------------------------------------------------------------------------
	*/	
	//{
		
		private function toStringARGB( radix:int = 16 ):String
		{
			const str:String =
					"A: " + (( value >> 24 ) & 0xFF).toString( radix ).toUpperCase() 
				+ "R: " + (( value >> 16 ) & 0xFF).toString( radix ).toUpperCase() 
				+ "G: " + (( value >> 8 ) & 0xFF).toString( radix ).toUpperCase() 
				+ "B: " + ( value  & 0xFF).toString( radix ).toUpperCase();
				
				return str;
				
		}
		
		
	//}
		
		
	}

}